Global Space
Global space contains the location and dimensions of a shape after the mapping in its associated view port has been applied. Global space defines the real-world location and dimensions of a shape; coordinate values in global space represent distance in points
(72 per inch) from the origin of the view group that the view port is part of.As this stage in drawing a shape, QuickDraw GX converts the shape from local space to global space. It modifies the shape's dimensions by applying first the mapping and then the clip contained in the view port object attached to the shape's transform. Because the view port clip is applied after the view port mapping, the dimensions of the clip shape are considered to be in global space. When you define the clip of a view port object, you size it and position it in terms of global space (the view port's position compared to view devices), not local space (the shape's position in its view port).
If the view port to which drawing occurs is a child view port in a view port hierarchy, QuickDraw GX performs mapping and clipping operations on all view ports in turn from that child view port through the top (root) view port; the result of all those mapping transformations is considered global space for the shape. See the section "Parent and Child View Ports" beginning on page 7-18 for information about view port hierarchies.
The example vase shape shown in the previous figures is drawn into the child view port of a simple two-level hierarchy. The left side of Figure 7-16 shows the vase shape after the child view port mapping has been applied to it. In this particular example, the effect of the view port mapping is to move the shape downward and to the left by approximately 50 units, representing a scrolling of the shape from its original position. There is no scale factor or other distortion in this case, so the dimensions of the shape are unchanged. The shape is not yet in global space, however, because another mapping (from the parent view port) must be applied.
Figure 7-16 Applying the child view port's mapping and clip to a shape
The right side of Figure 7-16 shows the vase shape after the child view port clip has been applied to it. The view port clip in this case is a rectangle that defines the visible portion of the child view port. As Figure 7-16 shows, the clip cuts out the left half of the vase (shaded gray), meaning that part of the shape has been scrolled out of view in its view port. The clip's dimensions, although not yet in global space (because the parent view port mapping has not yet been applied), are "global" to the child view port; changing the child view port's mapping, for example, does not change the position of its clip in relation to its parent view port. Therefore, to scroll a shape in a view port, you need only change the view port's mapping, not its clip.
This example shows a single shape drawn into a single view port, but more complex arrangements are possible. For example, as shown in Figure 7-3 on page 7-10, a single transform object can reference several view port objects, allowing a single shape to appear simultaneously (perhaps with different scaling or orientation) in several view ports.
Figure 7-17 completes the process of conversion from local to global space. The left side of Figure 7-17 shows the vase shape after the parent view port mapping has been applied to it. In this example, the effect of the view port mapping is to move the shape to the right and downward by approximately 50 units, representing the actual location of the shape in global space. Again, there is no scale factor or other distortion applied in this case, so the dimensions of the shape are unchanged. Because this view port is the root view port, the shape is now in global space and its dimensions can be measured. The visible part of the shape is approximately 50 points by 200 points in size, or about
0.7 by 2.8 inches.Figure 7-17 Applying the parent view port's mapping and clip to a shape
The right side of Figure 7-17 shows the vase shape after the parent view port clip has been applied to it. This view port clip is a rectangle that defines, in global space, the content area of the window to which the parent view port is attached. As is typical for a simple window that supports scrolling, the clips of the child view port and parent view port differ only by the areas of the scroll bars; the child view port clip fits inside the scroll bars so that drawing into it does not obliterate the scroll bars. In this case, the application of the parent view port clip has no effect on the visibility of the vase shape because the child view port clip is entirely contained within it.
As this example shows, you typically use the parent view port's mapping to position
the window you are drawing into, and its clip to restrict drawing to the interior of the window. You use mappings of child view ports to scroll, scale, or move shapes in relation to the parent view port, and you use their clips to restrict the shapes' visibilities in relation to the parent view port. If a parent view port is attached to a window (through theGXNewWindowViewPort
call), QuickDraw GX itself manipulates both the clip and mapping of the parent view port to make sure its location and drawable area correspond to the visible parts of the content area of the window. (Strictly speaking, QuickDraw GX prevents drawing from occurring outside of the visible part of the content area of the window, but it does not necessarily use the view port's clip to do so; if you retrieve the clip of a window view port, it is not guaranteed to be equal to either the window's port rectangle or its visible region.)Global space is view-group space. Keep in mind these ways in which view groups and global space define the interactions among view ports and view devices:
To draw the device-independent shapes in a view group with maximum accuracy on view devices of varying positions and resolutions requires conversion from global space to device space, as described next.
- Once a shape's dimensions have been converted to global space, it has an absolute size and a specific spatial relationship to all other shapes in that view group, whether or not the shapes share the same local space (view port).
- Global-space dimensions are device-independent and therefore resolution independent; for typical drawing operations, you need never know the resolutions of the devices you are drawing to.
- Within a view group, the clips of view ports and view devices can overlap in any combination. Drawing occurs automatically wherever the visible portions of any view port and any view device in that view group overlap.
- More than one view group can exist simultaneously, allowing for offscreen drawing. Furthermore, the view ports referenced by the transform of a single shape need not all be in the same view group, allowing for simultaneous onscreen and offscreen drawing of a shape.